IF exists(SELECT * FROM dbo.sysobjects WHERE name='WEB_menuSocialeCategorie' AND xtype='P') 
BEGIN
	DROP PROCEDURE WEB_menuSocialeCategorie
END
GO

CREATE procedure WEB_menuSocialeCategorie(@iNr char(7))
as
set nocount on
select socialeInfo as menu, socialeCategorie as kies 
	from (select socialeInfo from leerlingen..menuSocialeInfo union
	      select socialeCategorie from leerlingen..persoonlijkeGegevens2
	 	where inschrijvingsNr=@iNr
		and socialeCategorie is not null)  as m 
	 left join (select socialeCategorie from leerlingen..persoonlijkeGegevens2
	 where inschrijvingsNr=@iNr) as p
	 on p.socialeCategorie = m.socialeInfo 